package com.corpdata.app.customer.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.corpdata.app.contract.service.ContractInfoService;
import com.corpdata.app.customer.dao.CustomerStaffMapper;
import com.corpdata.app.customer.entity.CustomerStaff;
import com.corpdata.app.customer.service.CustomerStaffService;
import com.corpdata.common.utils.CorpdataUtil;
import com.corpdata.core.base.AbstractBaseService;


/**
 * 团队员工
 * 
 * @author wu
 * @email 64088839@qq.com
 * @date 2018-06-13 16:46:46
 */
@Service
@Transactional
public class CustomerStaffServiceImpl extends AbstractBaseService<CustomerStaff> implements CustomerStaffService {
	
	@Autowired
	private CustomerStaffMapper customerStaffMapper;
	
	@Autowired
	private ContractInfoService contractInfoService;
	
	/**
	 * 获取下拉json数据
	 * @return
	 */
	public String selectAllByCombox(String id){
		String json = CorpdataUtil.getComboxJson(customerStaffMapper.selectAllByCombox(id));
		return json;
	}
	
	public List<CustomerStaff> selectByPid(String pid){
		List<CustomerStaff> list =customerStaffMapper.selectByPid(pid);
		return list;
	}
	
	public String selStaff(String id){
		return JSON.toJSONStringWithDateFormat(super.findById(id),"yyyy-MM-dd");
	}
	
	public int selectAll(String teamId){
		Map<String,Object> params = new HashMap<String,Object>();
		if(null !=teamId && !("").equals(teamId)){
			params.put("teamId",teamId );
		}
		
		return customerStaffMapper.selectCount(params);
	}
}
